﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ggdll.GGMessages.Outgoing
{
    class GGMessageNotifyContacts
    {
        private static int message_type = (int)GGMessageType.GG_NOTIFY_LAST;
        public List<GGContacts.GGContact> contacts = new List<GGContacts.GGContact>();
        private int message_size;

        public byte[] getBytes()
        {
            int message_pos = 8;
            message_size = contacts.Count * 5;
            byte[] response = new byte[message_size + 8];

            System.Buffer.BlockCopy(BitConverter.GetBytes(message_type), 0, response, 0, 4);
            System.Buffer.BlockCopy(BitConverter.GetBytes(message_size), 0, response, 4, 4);
            foreach (GGContacts.GGContact it in contacts)
            {
                System.Buffer.BlockCopy(BitConverter.GetBytes(it.Uin), 0, response, message_pos, 4);
                message_pos += 4;
                response[message_pos] = 1;
                message_pos += 1;
            }
            return response;
        }
    }
}
